import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:中序排列
 * User: wangxin
 * Date: 2024-11-05
 * Time: 22:24
 */




public class test2 {
    public void inorder(TreeNode root, List<Integer> list){
        if(root == null){
            return;
        }
        inorder(root.left,list);
        list.add(root.val);
        inorder(root.right,list);
    }
    public int[] inorderTraversal (TreeNode root) {
        // write code here
        List<Integer> list = new ArrayList<>();
        inorder(root,list);
        int[] arr = new int[list.size()];
        for(int i = 0; i < list.size();i++){
            arr[i] = list.get(i);
        }
        return arr;
    }
}
